namespace PickGold.Charting
{
    using System;
    using System.ComponentModel;

    internal class DynamicPropertyDescriptor : PropertyDescriptor
    {
        private PropertyDescriptor _basePropertyDescriptor;
        private string _displayName;

        public DynamicPropertyDescriptor(PropertyDescriptor basePropertyDescriptor, string displayName) : base(basePropertyDescriptor)
        {
            this._displayName = string.Empty;
            this._displayName = displayName;
            this._basePropertyDescriptor = basePropertyDescriptor;
        }

        public override bool CanResetValue(object component)
        {
            return this._basePropertyDescriptor.CanResetValue(component);
        }

        public override object GetValue(object component)
        {
            return this._basePropertyDescriptor.GetValue(component);
        }

        public override void ResetValue(object component)
        {
            this._basePropertyDescriptor.ResetValue(component);
        }

        public override void SetValue(object component, object value)
        {
            this._basePropertyDescriptor.SetValue(component, value);
        }

        public override bool ShouldSerializeValue(object component)
        {
            return this._basePropertyDescriptor.ShouldSerializeValue(component);
        }

        public override Type ComponentType
        {
            get
            {
                return this._basePropertyDescriptor.ComponentType;
            }
        }

        public override string DisplayName
        {
            get
            {
                if (this._displayName.Length > 0)
                {
                    return this._displayName;
                }
                return this._basePropertyDescriptor.DisplayName;
            }
        }

        public override bool IsBrowsable
        {
            get
            {
                return this._basePropertyDescriptor.IsBrowsable;
            }
        }

        public override bool IsReadOnly
        {
            get
            {
                return this._basePropertyDescriptor.IsReadOnly;
            }
        }

        public override Type PropertyType
        {
            get
            {
                return this._basePropertyDescriptor.PropertyType;
            }
        }
    }
}

